﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Test
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Application.EnableVisualStyles();
            // Application.SetCompatibleTextRenderingDefault(false);
            // Application.Run(new Form2());

            
            float[] data1 = new float[10];
            float[] data2 = new float[10];
            float[] data3 = new float[10];
            for (int i = 0; i < 10; i++)
            {
                data1[i] = (float)(0.1+0.1 * i);
                data2[i] = (float)(0.9+0.1 * i);
                data3[i] = (float)(1.7+0.1 * i);
            }
            List<float[]> data = new List<float[]>();
            data.Add(data1);
            data.Add(data2);
            data.Add(data3);
            float overlap = (float)0.2;

            float dataLen = data[0].Length;//单层长度
            int count = data.Count;//层数
            float overlapNum;//单层数组重复率
            float[,] rawDataArray = new float[count,(int)dataLen];//二维的输出数组
            float rawLen = dataLen;//一维数组长度累计
            overlapNum = dataLen * overlap;//重叠数

            //首层赋值
            for (int i = 0; i < dataLen; i++)
            {
                rawDataArray[0, i] = data[0][i];
            }
            
            //去掉重叠部分
            for (int i = 1; i < count; i++)
            {
                for (int j = 0; j < dataLen - overlapNum; j++)
                {
                    rawDataArray[i,j] = data[i][j + (int)overlapNum];
                }
                rawLen = rawLen + dataLen - overlapNum;
            }

            float[] rawData = new float[(int)rawLen];//一维输出数组
            //二维数组转换成一维数组
            int k = 0;
            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < dataLen; j++)
                {
                    if (rawDataArray[i, j] == 0) continue;
                    rawData[k] = rawDataArray[i,j];
                    k++;
                }
            }
            PrintArray(data1);
            PrintArray(data2);
            PrintArray(data3);
            PrintArray(rawData);


        }
        static void PrintArray(float[] a)//具体数组类型可根据实际更改
        {
            //需要对输入数组判断是否为空
            if (a.Length != 0)
            {
                string str = "";
                foreach (var i in a)
                {
                    str = str + i + ",";
                }

                Console.WriteLine("[" + str.Substring(0, str.Length - 1) + "]");//通过Substring()去除对应字符
            }
            if (a.Length == 0) Console.WriteLine("[]");//如果数组为空，打印空数组格式即可
        }

    }
}
